
export const push = function (obj) {
	let url = obj.path + (obj.path.indexOf('?') < 0 ? '?' : '&') + param(obj.query)
	// console.log(url)
	uni.navigateTo({
		url
	}) 
}
export const redirect = function (obj) {
	let url = obj.path + (obj.path.indexOf('?') < 0 ? '?' : '&') + param(obj.query)
	uni.redirectTo({
		url
	})
}
export const reLaunch = function (obj) {
	let url = obj.path + (obj.path.indexOf('?') < 0 ? '?' : '&') + param(obj.query)

	uni.reLaunch({
		url
	})

}
export const switchTab = function (obj) {
	let url = obj.path + (obj.path.indexOf('?') < 0 ? '?' : '&') + param(obj.query)
// console.log(url)
	uni.switchTab({
		url
	})
}

export const goBack = function (backNum = 1) {
	uni.navigateBack({
		delta: backNum
	});
}
export function param(data) {
	let url = ''
	for (var k in data) {
		let value = data[k] !== undefined ? data[k] : ''
		url += '&' + k + '=' + encodeURIComponent(value)
	}
	return url ? url.substring(1) : ''
}
